<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/7/4
 * Time: 21:38
 */

//冒泡排序（数组排序）
/**
 * @param $array
 *
 * @return bool
 *
 */
function bubble_sort( $array ) {
	$count = count( $array );
	if ( $count <= 0 ) {
		return false;
	}
	for ( $i = 0; $i < $count; $i ++ ) {
		for ( $j = $i; $j < $count - 1; $j ++ ) {
			if ( $array[ $i ] > $array[ $j ] ) {
				$tmp         = $array[ $i ];
				$array[ $i ] = $array[ $j ];
				$array[ $j ] = $tmp;
			}
		}
	}

	return $array;
}

var_dump( bubble_sort( [ 3, 5, 1, 0, 8, 4 ] ) );